
var baseTool = {
    inArray: function (value, array) {
        var status = false;
        for (var key in array) {
            if (array[key] == value) {
                status = true;
            }
        }
        return status;
    },
    //格式化空数据
    formatEmpty: function (value) {
        if(!value && typeof(value) != "undefined" && value != 0) {
            return "";
        }
        return value;
    },
    /**
     * 格式化时间戳
     * @param time 时间戳,以秒为单位,默认为当前时间,如:1475204972
     * @param format 时间格式,如yyyy-MM-dd h:m:s
     */
    formatDate: function (time,format) {
        if(typeof(time) == "undefined" || time == "" || time === null){
            return "";
        }
        var date = new Date();
        date.setTime(time*1000);
        if(typeof(format) == "undefined"){
            format = "yyyy-MM-dd h:m:s";
        }
        Date.prototype.format = function(format) {
            var dateObj = {
                "M+": this.getMonth() + 1,
                "d+": this.getDate(),
                "h+": this.getHours(),
                "m+": this.getMinutes(),
                "s+": this.getSeconds(),
                "q+": Math.floor((this.getMonth() + 3) / 3),
                "S+": this.getMilliseconds()
            };
            if (/(y+)/i.test(format)) {
                format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
            }
            for (var k in dateObj) {
                if (new RegExp("(" + k + ")").test(format)) {
                    var tmp = dateObj[k];
                    tmp = tmp.toString();
                    while(tmp.length < 2){
                        tmp = '0' + tmp;
                    }
                    format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? tmp : ("00" + tmp).substr(("" + tmp).length));
                }
            }
            return format;
        };
        return date.format(format);
    },
};